<?php
class Zendvn_String_ConvertTag{

	public function convert($value = null, $tag = null,$option = null){
		
		if($tag == 'script'){
			$string = $this->scriptTag($value);
		}
		
		if($tag == 'style'){
			$string = $this->styleTag($value);
		}
		
		if($tag == null){
			$string = $this->scriptTag($value);
			$string = $this->styleTag($string);
		}
		
		return $string;
	}
	
	public function scriptTag($value){
		$string = preg_replace(array('#<script([^>]*)>#i', '#</script([^>]*)>#i'), 
	    			 			array('<pre>&lt;script\\1&gt;', '&lt;/script\\1&gt;</pre>'), 
	    			 			$value);
	   	
	   	return $string;
	}
	
	public function styleTag($value){
		$string = preg_replace(array('#<style([^>]*)>#i', '#</style([^>]*)>#i'), 
	    			 			array('<pre>&lt;style\\1&gt;', '&lt;/style\\1&gt;</pre>'), 
	    			 			$value);
	   	return $string;
	}
}